package com.jddup.program.etm;

import com.jddup.common.annotations.ColumnDes;
import com.jddup.common.pojo.TableColumn;

/**
 * Created by ZZB on 2017/12/3.
 */
public interface TableColumnColumnDesConvertor {
    default void setCommonPropertiesInTableColumn(TableColumn tableColumn, ColumnDes columnDes){
        if (columnDes.maxLength() != 0) {
            tableColumn.setMaxLength(columnDes.maxLength());
        }
        if (columnDes.scale() != 0) {
            tableColumn.setScale(columnDes.scale());
        }
        if (tableColumn.getNullable()== null) {
            tableColumn.setNullable(columnDes.isNullable());
        }
        if (!columnDes.defaultValue().equals("")) {
            tableColumn.setDefaultValue(columnDes.defaultValue());
        }
        if (columnDes.precision()!=0) {
            tableColumn.setPrecision(columnDes.precision());
        }
        tableColumn.setComment(columnDes.comment());
        tableColumn.setSigned(columnDes.signed());
    }

    void convertFromColumnDes(String tableName, TableColumn tableColumn, ColumnDes columnDes);
}
